package v9.assist.analyst

import android.graphics.Bitmap
import kotlinx.coroutines.script.Block
import kotlinx.coroutines.script.TARGET
import kotlinx.coroutines.script.SMapBase.hitDeathRed
import kotlinx.coroutines.script.SMapBase.hitEquipO
import kotlinx.coroutines.script.SMapBase.hitSMapEnemyBlue
import kotlinx.coroutines.script.SMapBase.hitSMapEnemyYellow
import kotlinx.coroutines.script.SMapBase.hitTeammate
import kotlinx.coroutines.script.tes.ColorDiffer
import kotlinx.coroutines.script.tes.printLog
import kotlinx.coroutines.script.tes.pt
import kotlinx.coroutines.script.tes.rgb
import kotlinx.coroutines.script.tes.shake
import v9.assist.script.sLastFeature30Ts
import v9.assist.script.xBossBesideTs
import v9.assist.script.xLastAtkTs
import v9.assist.script.xLastPetBlacksmithTs
import v9.assist.script.xLastReviveTs
import v9.assist.script.xLastSceneEnterTs
import v9.assist.script.xLastUnknownTs
import kotlin.math.abs

private val hitRoad by lazy { // 21-28
    val out = mutableSetOf<ColorDiffer>()
    out.addAll(setOf(0xff42443F.toInt().rgb(24),)) // 仪式2
    out.addAll(hitEquipO)
    out.addAll(hitDeathRed)
    out.addAll(hitTeammate)
    out.addAll(hitSMapEnemyYellow)
    out.addAll(hitSMapEnemyBlue)
    out
}
// p1 往上  p2 往左边 p3往右边 . p4 往左走快到boss
private var preToP3Counter = 0
private var preToP3CounterTs = 0L
var anaPathfindingModeYW = MODE_PATHFINDING_P1
var anaLastSMapYWFeature1Ts = 0L // 副本起点
var anaLastSMapYWFeature3Ts = 0L // 直通 估计没处理
var anaLastSMapYWFeature4Ts = 0L // 切换P2左边
var anaLastSMapYWFeature5Ts = 0L // 切换P3往右边
var anaLastSMapYWFeature6Ts = 0L // 切换P4
var anaLastSMapYWFeature7Ts = 0L //
var anaLastSMapYWFeature8Ts = 0L //
var anaLastSMapYWFeature9Ts = 0L // Boss终点
var anaLastSMapYWFeature10Ts = 0L // 副本外入口
var anaLastSMapYWFeature11Ts = 0L // 起点死路
var anaLastSMapYWFeature12Ts = 0L // P4死路
var anaLastSMapYWFeature13Ts = 0L // 第1个Boss击破门口
var anaLastSMapYWFeature15Ts = 0L
var sceneYWStateToP4Ts = 0L // 切换到P4
var sceneYWStateToP2Ts = 0L // 切换到P4
var anaLastSMapYWFeature16Ts = 0L
var anaLastSMapYWFeature17Ts = 0L
var anaLastSMapYWFeature18Ts = 0L // 节点.P4走过头了.回头触发Boss A
var anaLastSMapYWFeature19Ts = 0L //  开局卡点A
var anaLastSMapYWFeature20Ts = 0L //  开局卡点B
var anaLastSMapYWFeature21Ts = 0L //  P3右上测墙边卡点
var anaLastSMapYWFeature22Ts = 0L //  开局P1卡树怪
var anaLastSMapYWFeature23Ts = 0L //
var anaLastSMapYWFeature24Ts = 0L // 节点.P4走过头了.回头触发Boss B
var anaLastSMapYWFeature25Ts = 0L // 节点.P4走过头了.回头触发Boss C

fun rasterizeMapYW(ss: Bitmap): Array<IntArray> {
    return rasterizeMap(ss, hitRoad)
}

fun analysisMapYW(ss: Bitmap) {
    analysisMapElements(ss)
    val returnMapArray = rasterizeMapYW(ss)

    val te = mapEnemyList.randomOrNull()
    val lastSMapTargetToEnemyDs = if (te == null) Int.MAX_VALUE else mapElementDistance(te)

    if (blockEliteEnemyBoss != null && mapEnemyList.isNotEmpty()
        && anaPathfindingModeYW != MODE_PATHFINDING_P2
        && anaPathfindingModeYW != MODE_PATHFINDING_P3
        && System.currentTimeMillis() - lastSMapTargetToNpcTs > 50000) {
        // 优先Boss
        mapTargetList.add(mapEnemyList.random())
        printLog { "analyst target to boss" }
        lastSMapTargetToBossTs = System.currentTimeMillis()
        if (mapElementDistance(blockEliteEnemyBoss) < 30.pt) xBossBesideTs = System.currentTimeMillis()

        // 打最终boss保留状态4 anaPathfindingModeYW = MODE_PATHFINDING_P1  // 去上面
    } else if (mapNpcList.isNotEmpty() && System.currentTimeMillis() - lastSMapTargetToBossTs > 6000) {
        mapTargetList.add(mapNpcList.random())
        printLog { "analyst target to npc" }
        lastSMapTargetToNpcTs = System.currentTimeMillis()
    } else if (lastSMapTargetToEnemyDs < 60
        && System.currentTimeMillis() - anaLastPageSceneEnterTs > 10000 // 刚开局就需要
        && System.currentTimeMillis() - anaLastSceneSettleTs > 20000
        && !bsSceneSettle && !bsSceneSettleBlacksmith) {
        // 优先敌人
        mapTargetList.add(mapEnemyList.random())
        printLog { "analyst target to elite enemy" }
    } else if (bsSceneSettleBlacksmith && mapBlacksmithList.isNotEmpty()) {
        mapTargetList.add(mapBlacksmithList.random())
        printLog { "analyst target to blacksmith" }
    } else if (bsSceneSettle && mapBlueDoorList.isNotEmpty()) {
        mapTargetList.add(mapBlueDoorList.random())
        printLog { "analyst target to blueDoor" }
    } else if (mapRedDotList.size > 10 && anaPathfindingModeYW == MODE_PATHFINDING_P4) {
        mapRedDotList.minByOrNull { it.second }?.also {
            mapTargetList.add(it)
            printLog { "analyst target to red dot" }
        }
    } else if (mapSampleArrived.isNotEmpty()) {
        if (anaPathfindingModeYW == MODE_PATHFINDING_P1) {
            mapSampleArrived.minByOrNull { it.first + it.second * 2 }?.also {
                mapTargetList.add(it)
                printLog { "analyst target to sample top" } //
            }
        } else if (anaPathfindingModeYW == MODE_PATHFINDING_P2 ) {
            mapSampleArrived.minByOrNull { it.first }?.also {
                mapTargetList.add(it)
                printLog { "analyst target to sample left" } //
            }
        } else if (anaPathfindingModeYW == MODE_PATHFINDING_P3) {
            if (mapRightNotArrived.isNotEmpty()) {
                mapRightNotArrived.maxByOrNull { it.second }?.also {
                    mapTargetList.add(it)
                    printLog { "analyst target to bottom right" } //
                }
            } else {
                mapTopNotArrived.maxByOrNull { it.first }?.also {
                    mapTargetList.add(it)
                    printLog { "analyst target to top right" } //
                }
            }
        } else if ( anaPathfindingModeYW == MODE_PATHFINDING_P4 ) {
            mapBottomNotArrived.minByOrNull { it.first }?.also {
                mapTargetList.add(it)
                printLog { "analyst target to bottom left" } //
            }
        }
    }

    if (mapTargetList.isNotEmpty()) {
        val target = mapTargetList.random()
        returnMapArray[target.first][target.second] = TARGET
    }

    angleByRoad = analysisRasterizeMap(returnMapArray)
    angleByRoad = angleSpecialAdjust(angleByRoad ?: 340.shake(10))

     if (System.currentTimeMillis() - lastEliteEnemyBossTs > 10000
        && System.currentTimeMillis() - lastMapTopNotArrivedTs > 2000
        && System.currentTimeMillis() - lastMapBottomNotArrivedTs < 1000
        && System.currentTimeMillis() - lastMapLeftNotArrivedTs > 2000
        && System.currentTimeMillis() - lastMapRightNotArrivedTs < 1000
        && lastMapTopP == null
        && (lastMapBottomP ?: -1f) in 0.40 .. 0.64
        && lastMapLeftP == null
        && (lastMapRightP ?: -1f) in 0.82 .. 0.99) {
        printLog { "analystYW 节点.去最终boss F" }
        // 击破了boss 还能卡外面
        // [上,34s,c:0][下,0s,0.49130812,c:65][左,34s,c:0][右,0s,0.9178537,c:9]][Road,c:70]
        // [上,19s,c:0][下,0s,0.529661,c:88][左,13s,c:0][右,0s,0.91773504,c:16]][Road,c:59]
        // [上,35s,c:0][下,0s,0.5187438,c:85][左,29s,c:0][右,0s,0.93978244,c:11]][Road,c:52]
        // [上,37s,c:0][下,0s,0.5187438,c:85][左,30s,c:0][右,0s,0.93978244,c:11]][Road,c:53]
        // [上,48s,c:0][下,0s,0.529661,c:88][左,41s,c:0][右,0s,0.91773504,c:16]][Road,c:60]
        anaLastSMapYWFeature8Ts = System.currentTimeMillis()
        anaPathfindingModeYW = MODE_PATHFINDING_P4
        sceneYWStateToP4Ts = System.currentTimeMillis()
    }
    // map feature
    analysisMapYWIsStartPoint()
    printLog { "analystYW $mapSimpleStatus" }
    if ((blockBlueDoor == null || blockBlacksmith == null)
        && System.currentTimeMillis() - lastEliteEnemyBossTs > 10000) {
        printLog { "analystYW $mapSimpleStatus" }
        if (System.currentTimeMillis() - lastMapTopNotArrivedTs < 1000
            && System.currentTimeMillis() - lastMapBottomNotArrivedTs > 2000
            && System.currentTimeMillis() - lastMapLeftNotArrivedTs < 1000
            && System.currentTimeMillis() - lastMapRightNotArrivedTs > 2000
            && (lastMapTopP ?: -1f) in 0.22 .. 0.32
            && lastMapBottomP == null
            && (lastMapLeftP ?: -1f) in 0.38 .. 0.48
            && lastMapRightP == null
            && System.currentTimeMillis() - xLastAtkTs > 4000
            && System.currentTimeMillis() - lastBlueDoorTs < 2000
            && System.currentTimeMillis() - xLastUnknownTs > 6000
            && System.currentTimeMillis() - xLastSceneEnterTs > 8000
        ) {
            printLog { "analystYW 节点.直通3" }
            // [上,0s,0.26836157,c:62][下,1741875942s,c:0][左,0s,0.44242015,c:19][右,1741875942s,c:0]][Road,c:25]
            // [上,0s,0.28243798,c:59][下,1741875980s,c:0][左,0s,0.43564606,c:17][右,1741875980s,c:0]][Road,c:24]
            anaLastSMapYWFeature3Ts = System.currentTimeMillis()
        } else if (System.currentTimeMillis() - lastMapTopNotArrivedTs < 1000
            && System.currentTimeMillis() - lastMapBottomNotArrivedTs < 1000
            && System.currentTimeMillis() - lastMapLeftNotArrivedTs < 1000
            && System.currentTimeMillis() - lastMapRightNotArrivedTs < 1000
            && (lastMapTopP ?: -1f) in 0.57 .. 0.63
            && (lastMapBottomP ?: -1f) in 0.41 .. 0.51
            && (lastMapLeftP ?: -1f) in 0.41 .. 0.51
            && (lastMapRightP ?: -1f) in 0.26 .. 0.32
            && System.currentTimeMillis() - lastSMapTargetToNpcTs > 3000
            && System.currentTimeMillis() - xLastReviveTs > 30000) {
            // [上,0s,0.6046391,c:71][下,0s,0.48527467,c:47][左,0s,0.4679487,c:26][右,0s,0.2994367,c:44]][Road,c:106]
            // [上,0s,0.6066212,c:82][下,0s,0.44085452,c:64][左,0s,0.4846154,c:25][右,0s,0.29895103,c:44]][Road,c:107]
           // [上,0s,0.61174285,c:79][下,0s,0.47269303,c:60][左,0s,0.47309276,c:27][右,0s,0.29009554,c:34]][Road,c:106]
            printLog { "analystYW 节点.P1切换P2去往下开门B " }
            anaLastSMapYWFeature4Ts = System.currentTimeMillis()
        } else if (System.currentTimeMillis() - lastMapTopNotArrivedTs < 1000
            && System.currentTimeMillis() - lastMapLeftNotArrivedTs < 1000
            && (lastMapTopP ?: -1f) in 0.47 .. 0.63
            && lastMapTopC in 40 .. 150 // 这个开局可能有13个是错误的.避免去左边死角
            && (lastMapLeftP ?: -1f) in 0.45 .. 0.69
            && System.currentTimeMillis() - lastSMapTargetToNpcTs > 3000
            && System.currentTimeMillis() - xLastReviveTs > 30000 //直接正门去boss
            && anaPathfindingModeYW == MODE_PATHFINDING_P1) {
            // [上,1737556383s,c:0][下,0s,0.7542373,c:24][左,1737556383s,c:0][右,1737556383s,c:0]][Road,c:7]
            // [上,0s,0.54273003,c:87][下,0s,0.6662631,c:7][左,0s,0.530044,c:33][右,1741787460s,c:0]][Road,c:76]
            // [上,0s,0.55134964,c:90][下,3s,c:0][左,0s,0.525641,c:30][右,3s,c:0]][Road,c:75]
            // [上,0s,0.5694108,c:84][下,0s,0.31882817,c:89][左,0s,0.664751,c:58][右,0s,0.4382716,c:18]][Road,c:90]
            printLog { "analystYW 节点.P1切换P2去往下开门A " }
            anaLastSMapYWFeature4Ts = System.currentTimeMillis()

        } else if (System.currentTimeMillis() - lastMapTopNotArrivedTs < 1000
            && System.currentTimeMillis() - lastMapLeftNotArrivedTs > 2000
            && System.currentTimeMillis() - lastMapRightNotArrivedTs < 1000
            && (lastMapTopP ?: -1f) in 0.85 .. 0.99
            && lastMapLeftP == null
            && (lastMapRightP ?: -1f) in 0.35 .. 0.59
            && !bsSceneSettle && !bsSceneSettleBlacksmith
            && System.currentTimeMillis() - anaLastSceneSettleTs > 30000
            && anaPathfindingModeYW != MODE_PATHFINDING_P3
            && anaPathfindingModeYW != MODE_PATHFINDING_P4) {
            // [上,0s,0.9456215,c:16][下,0s,0.8333333,c:2][左,21s,c:0][右,0s,0.42320842,c:65]][Road,c:33]
            // [上,0s,0.91514957,c:27][下,0s,0.9595103,c:3][左,19s,c:0][右,0s,0.50491744,c:73]][Road,c:37]
            if (System.currentTimeMillis() - preToP3CounterTs > 10000) preToP3Counter = 0
            printLog { "analystYW 节点.副本.P2最左侧切换P3去右边 $preToP3Counter" }
            preToP3Counter++
            preToP3CounterTs = System.currentTimeMillis()
            if (preToP3Counter > 7) {
                printLog { "analystYW 节点.副本.P2最左侧切换P3去右边 [执行]" }
                anaPathfindingModeYW = MODE_PATHFINDING_P3
                anaLastSMapYWFeature5Ts = System.currentTimeMillis()
            }
        } else if (System.currentTimeMillis() - lastMapTopNotArrivedTs > 2000
            && System.currentTimeMillis() - lastMapBottomNotArrivedTs < 1000
            && System.currentTimeMillis() - lastMapLeftNotArrivedTs < 1000
            && System.currentTimeMillis() - lastMapRightNotArrivedTs > 2000
            && lastMapTopP == null
            && (lastMapBottomP ?: -1f) in 0.30 .. 0.40
            && (lastMapLeftP ?: -1f) in 0.67 .. 0.83
            && lastMapRightP == null) {
            // [上,21s,c:0][下,0s,0.34092513,c:64][左,0s,0.76495725,c:44][右,48s,c:0]][Road,c:42]
            // [上,53s,c:0][下,0s,0.35381356,c:64][左,0s,0.75204587,c:47][右,81s,c:0]][Road,c:43]
            // [上,54s,c:0][下,0s,0.36356354,c:67][左,0s,0.75874126,c:44][右,81s,c:0]][Road,c:47]
            printLog { "analystYW 节点.切换P4去左边 A" }
            anaLastSMapYWFeature6Ts = System.currentTimeMillis()
            anaPathfindingModeYW = MODE_PATHFINDING_P4
            sceneYWStateToP4Ts = System.currentTimeMillis()
        } else if (System.currentTimeMillis() - lastMapTopNotArrivedTs > 2000
            && System.currentTimeMillis() - lastMapBottomNotArrivedTs < 1000
            && System.currentTimeMillis() - lastMapRightNotArrivedTs > 2000
            && lastMapTopP == null
            && (lastMapBottomP ?: -1f) in 0.29 .. 0.44
            && (lastMapLeftP == null || (lastMapLeftP ?: -1f) in 0.87 .. 0.95)
            && lastMapRightP == null
            && anaPathfindingModeYW != MODE_PATHFINDING_P1) {
            // [上,26s,c:0][下,0s,0.3799435,c:78][左,22s,c:0][右,35s,c:0]][Road,c:34]
            // [上,13s,c:0][下,0s,0.32509094,c:73][左,10s,c:0][右,35s,c:0]][Road,c:37]
            // [上,23s,c:0][下,0s,0.32109228,c:84][左,0s,0.9166667,c:4][右,31s,c:0]][Road,c:37]
            printLog { "analystYW 节点.切换P4去左边 B " }
            anaLastSMapYWFeature6Ts = System.currentTimeMillis()
            anaPathfindingModeYW = MODE_PATHFINDING_P4
            sceneYWStateToP4Ts = System.currentTimeMillis()
        } else if (System.currentTimeMillis() - lastMapTopNotArrivedTs < 1000
            && System.currentTimeMillis() - lastMapBottomNotArrivedTs < 1000
            && System.currentTimeMillis() - lastMapLeftNotArrivedTs < 1000
            && System.currentTimeMillis() - lastMapRightNotArrivedTs < 1000
            && (lastMapTopP ?: -1f) in 0.61 .. 0.69
            && (lastMapBottomP ?: -1f) in 0.43 .. 0.51
            && (lastMapLeftP ?: -1f) in 0.75 .. 0.83
            && (lastMapRightP ?: -1f) in 0.70 .. 0.78
        ) {
            //[上,0s,0.65966594,c:23][下,0s,0.47676328,c:31][左,0s,0.7991453,c:1][右,0s,0.74013025,c:21]][Road,c:72]
            printLog { "analystYW 节点.切换P4 特殊为最终Boss C" }
            anaPathfindingModeYW = MODE_PATHFINDING_P4
            sceneYWStateToP4Ts = System.currentTimeMillis()
        } else if (System.currentTimeMillis() - lastMapTopNotArrivedTs > 2000
            && System.currentTimeMillis() - lastMapBottomNotArrivedTs < 1000
            && System.currentTimeMillis() - lastMapLeftNotArrivedTs > 2000
            && System.currentTimeMillis() - lastMapRightNotArrivedTs < 1000
            && lastMapTopP == null
            && (lastMapBottomP ?: -1f) in 0.48 .. 0.56
            && lastMapLeftP == null
            && (lastMapRightP ?: -1f) in 0.60 .. 0.68
        ) {
            // [上,5s,c:0][下,0s,0.5211864,c:56][左,4s,c:0][右,0s,0.6495727,c:45]][Road,c:64]
            // [上,63s,c:0][下,0s,0.5210362,c:47][左,50s,c:0][右,0s,0.6336441,c:55]][Road,c:59]
            printLog { "analystYW 节点.切换P4 特殊为最终Boss D" }
            anaPathfindingModeYW = MODE_PATHFINDING_P4
            sceneYWStateToP4Ts = System.currentTimeMillis()
        } else if (System.currentTimeMillis() - lastMapTopNotArrivedTs > 2000
            && System.currentTimeMillis() - lastMapBottomNotArrivedTs < 1000
            && System.currentTimeMillis() - lastMapLeftNotArrivedTs > 2000
            && System.currentTimeMillis() - lastMapRightNotArrivedTs > 2000
            && lastMapTopP == null
            && (lastMapBottomP ?: -1f) in 0.44 .. 0.51
            && lastMapTopP == null
            && lastMapRightP == null
            && anaPathfindingModeYW == MODE_PATHFINDING_P3
        ) {
            // [上,63s,c:0][下,0s,0.48956975,c:65][左,63s,c:0][右,152s,c:0]][Road,c:30]
            printLog { "analystYW 节点.切换P4 特殊为最终Boss E" }
            anaPathfindingModeYW = MODE_PATHFINDING_P4
            sceneYWStateToP4Ts = System.currentTimeMillis()
        } else if (System.currentTimeMillis() - lastMapTopNotArrivedTs < 1000
            && System.currentTimeMillis() - lastMapBottomNotArrivedTs > 2000
            && System.currentTimeMillis() - lastMapLeftNotArrivedTs < 1000
            && System.currentTimeMillis() - lastMapRightNotArrivedTs < 1000
            && (lastMapTopP ?: -1f) in 0.33 .. 0.57
            && lastMapBottomP == null
            && (lastMapLeftP ?: -1f) in 0.09 .. 0.27
            && (lastMapRightP ?: -1f) in 0.63 .. 0.91
            && anaPathfindingModeYW == MODE_PATHFINDING_P3
            && System.currentTimeMillis() - lastEliteEnemyBossTs > 2000) {
            printLog { "analystYW 节点.P3从开始开锁的门去最右边 " }
            // [上,0s,0.41463113,c:68][下,8s,c:0][左,0s,0.153092,c:17][右,0s,0.83048433,c:15]][Road,c:61]
            // [上,0s,0.42931286,c:86][下,22s,c:0][左,0s,0.14102565,c:22][右,0s,0.8538462,c:20]][Road,c:54]
            // [上,0s,0.4072667,c:87][下,26s,c:0][左,0s,0.16632478,c:25][右,0s,0.85490435,c:21]][Road,c:50]
            // [上,0s,0.40761048,c:85][下,28s,c:0][左,0s,0.14697139,c:23][右,0s,0.8504273,c:22]][Road,c:52]
            // [上,0s,0.42076942,c:84][下,40s,c:0][左,0s,0.14548495,c:23][右,0s,0.86343366,c:23]][Road,c:54]
            // [上,0s,0.5400703,c:119][下,39s,c:0][左,0s,0.12192056,c:17][右,0s,0.6837607,c:24]][Road,c:59]
            // [上,0s,0.46337426,c:145][下,85s,c:0][左,0s,0.16666667,c:28][右,0s,0.525641,c:38]][Road,c:70]
            // [上,0s,0.3993644,c:72][下,58s,c:0][左,0s,0.22136752,c:25][右,0s,0.83653843,c:16]][Road,c:61]
            // [上,0s,0.3993644,c:72][下,101s,c:0][左,0s,0.22136752,c:25][右,0s,0.83653843,c:16]][Road,c:61]
            anaLastSMapYWFeature7Ts = System.currentTimeMillis()
        } else if (System.currentTimeMillis() - lastMapTopNotArrivedTs < 2000
            && System.currentTimeMillis() - lastMapBottomNotArrivedTs < 1000
            && System.currentTimeMillis() - lastMapLeftNotArrivedTs < 1000
            && System.currentTimeMillis() - lastMapRightNotArrivedTs < 1000
            && (lastMapTopP ?: -1f) in 0.51 .. 0.65
            && (lastMapBottomP ?: -1f) in 0.41 .. 0.87
            && (lastMapLeftP ?: -1f) in 0.21 .. 0.49
            && (lastMapRightP ?: -1f) in 0.19 .. 0.51
            && System.currentTimeMillis() - lastSMapTargetToNpcTs > 3000
            && anaPathfindingModeYW != MODE_PATHFINDING_P3) {
            printLog { "analystYW 节点.P1去开门的门上侧" }
            // [上,0s,0.6004667,c:92][下,0s,0.59745765,c:24][左,0s,0.43162394,c:29][右,0s,0.29956427,c:51]][Road,c:86]
            // [上,0s,0.5617863,c:94][下,0s,0.52259886,c:8][左,0s,0.3855219,c:33][右,0s,0.23024806,c:41]][Road,c:58]
            // [上,0s,0.6004667,c:92][下,0s,0.59083,c:26][左,0s,0.43276355,c:30][右,0s,0.29956427,c:51]][Road,c:85]
            // 靠下 [上,0s,0.5646096,c:78][下,0s,0.8361582,c:4][左,0s,0.2777778,c:32][右,0s,0.4467069,c:51]][Road,c:62]
            // [上,0s,0.57600033,c:73][下,0s,0.44915253,c:2][左,0s,0.26068377,c:14][右,0s,0.46786326,c:50]][Road,c:69]
            anaLastSMapYWFeature9Ts = System.currentTimeMillis()
        } else if (System.currentTimeMillis() - lastMapTopNotArrivedTs > 2000
            && System.currentTimeMillis() - lastMapBottomNotArrivedTs < 1000
            && System.currentTimeMillis() - lastMapLeftNotArrivedTs > 2000
            && System.currentTimeMillis() - lastMapRightNotArrivedTs > 2000
            && lastMapTopP == null
            && (lastMapBottomP ?: -1f) in 0.67 .. 0.85
            && lastMapRoadC < 18 // 实际5-9
            && lastMapLeftP == null
            && lastMapRightP == null
            && System.currentTimeMillis() - lastEliteEnemyBossTs > 12000) {
            // [上,1737556383s,c:0][下,0s,0.7542373,c:24][左,1737556383s,c:0][右,1737556383s,c:0]][Road,c:7]
            printLog { "analystYW 节点.副本外入口 " } // maybe//  [可以用sampleCount来区分] // boss前也有这个
            anaLastSMapYWFeature10Ts = System.currentTimeMillis()
            anaClearSceneSettle()
            anaPathfindingModeYW = MODE_PATHFINDING_P1 // p1 p2

        } else if (
//            System.currentTimeMillis() - lastMapTopNotArrivedTs < 1000
            System.currentTimeMillis() - lastMapBottomNotArrivedTs < 1000
            && System.currentTimeMillis() - lastMapLeftNotArrivedTs > 2000
            && System.currentTimeMillis() - lastMapRightNotArrivedTs > 2000
            && (lastMapTopP == null || (lastMapTopP ?: -1f) in 0.30 .. 0.44)
            && (lastMapBottomP ?: -1f) in 0.56 .. 0.80
            && lastMapLeftP == null
            && lastMapRightP == null) {
            // [上,0s,0.37304753,c:17][下,0s,0.70871973,c:53][左,11s,c:0][右,1741876269s,c:0]][Road,c:30]
            // [上,0s,0.37633398,c:18][下,0s,0.61667895,c:46][左,36s,c:0][右,1741876294s,c:0]][Road,c:32]
            // [上,0s,0.37570623,c:18][下,0s,0.76084864,c:47][左,10s,c:0][右,130s,c:0]][Road,c:29]
            // [上,0s,0.37570623,c:18][下,0s,0.72316384,c:52][左,1741879117s,c:0][右,42s,c:0]][Road,c:28]
            // [上,0s,0.38700566,c:16][下,0s,0.704652,c:47][左,1746258328s,c:0][右,1746258328s,c:0]][Road,c:35]
            printLog { "analystYW 节点.起点死路 " }
            anaLastSMapYWFeature11Ts = System.currentTimeMillis()
        } else if (System.currentTimeMillis() - lastMapTopNotArrivedTs < 1000
            && System.currentTimeMillis() - lastMapBottomNotArrivedTs < 1000
            && System.currentTimeMillis() - lastMapLeftNotArrivedTs < 1000
            && System.currentTimeMillis() - lastMapRightNotArrivedTs > 2000
            && (lastMapTopP ?: -1f) in 0.33 .. 0.45
            && (lastMapBottomP ?: -1f) in 0.21 .. 0.33
            && (lastMapLeftP ?: -1f) in 0.45 .. 0.57
            && lastMapRightP == null
            && anaPathfindingModeYW == MODE_PATHFINDING_P4) {
            // [上,0s,0.39741302,c:76][下,0s,0.27364284,c:92][左,0s,0.5175499,c:75][右,47s,c:0]][Road,c:75]
            // [上,0s,0.39741302,c:76][下,0s,0.27364284,c:92][左,0s,0.5125956,c:76][右,29s,c:0]][Road,c:75]
            printLog { "analystYW 节点.P4回头死路 " }
            anaLastSMapYWFeature12Ts = System.currentTimeMillis()
        } else if (System.currentTimeMillis() - lastMapTopNotArrivedTs < 1000
            && System.currentTimeMillis() - lastMapBottomNotArrivedTs > 2000
            && System.currentTimeMillis() - lastMapLeftNotArrivedTs < 1000
            && System.currentTimeMillis() - lastMapRightNotArrivedTs < 1000
            && (lastMapTopP ?: -1f) in 0.53 .. 0.61
            && lastMapBottomP == null
            && (lastMapLeftP ?: -1f) in 0.27 .. 0.35
            && (lastMapRightP ?: -1f) in 0.41 .. 0.49
            && anaPathfindingModeYW == MODE_PATHFINDING_P2
            ) {
            // [上,0s,0.5728996,c:62][下,71s,c:0][左,0s,0.31331533,c:19][右,0s,0.45014247,c:39]][Road,c:92]
            printLog { "analystYW 节点.P2 第1个Boss击破后左下角互动门口上侧 " }
            anaLastSMapYWFeature13Ts = System.currentTimeMillis()

        } else if (System.currentTimeMillis() - lastMapTopNotArrivedTs < 1000
            && System.currentTimeMillis() - lastMapBottomNotArrivedTs > 2000
            && System.currentTimeMillis() - lastMapLeftNotArrivedTs < 1000
            && System.currentTimeMillis() - lastMapRightNotArrivedTs < 1000
            && (lastMapTopP ?: -1f) in 0.52 .. 0.60
            && lastMapBottomP == null
            && (lastMapLeftP ?: -1f) in 0.23 .. 0.31
            && (lastMapRightP ?: -1f) in 0.38 .. 0.46
            && anaPathfindingModeYW == MODE_PATHFINDING_P3
        ) {
            // [上,0s,0.5602489,c:64][下,47s,c:0][左,0s,0.2767094,c:20][右,0s,0.42307693,c:40]][Road,c:89]
            printLog { "analystYW 节点.P3卡出去的门口" }
            anaLastSMapYWFeature15Ts = System.currentTimeMillis()
        } else if (System.currentTimeMillis() - lastMapTopNotArrivedTs < 1000
            && System.currentTimeMillis() - lastMapBottomNotArrivedTs < 1000
            && System.currentTimeMillis() - lastMapLeftNotArrivedTs < 1000
            && System.currentTimeMillis() - lastMapRightNotArrivedTs > 2000
            && (lastMapTopP ?: -1f) in 0.36 .. 0.44
            && (lastMapBottomP ?: -1f) in 0.23 .. 0.32
            && (lastMapLeftP ?: -1f) in 0.50 .. 0.58
            && lastMapRightP == null
            && anaPathfindingModeYW == MODE_PATHFINDING_P3
        ) {
            //  [上,0s,0.3970104,c:72][下,0s,0.2643473,c:57][左,0s,0.52747256,c:63][右,85s,c:0]][Road,c:87]
            // [上,0s,0.40176237,c:67][下,0s,0.28065804,c:68][左,0s,0.525641,c:65][右,23s,c:0]][Road,c:89]
            // 150 140 90 70
            // [上,0s,0.42806464,c:43][下,0s,0.28972706,c:71][左,0s,0.56043005,c:64][右,51s,c:0]][Road,c:89]
            printLog { "analystYW 节点.P3最右边的卡门.右下角走两步微调A" }
            anaLastSMapYWFeature16Ts = System.currentTimeMillis()
        } else if (System.currentTimeMillis() - lastMapTopNotArrivedTs < 1000
            && System.currentTimeMillis() - lastMapBottomNotArrivedTs < 1000
            && System.currentTimeMillis() - lastMapLeftNotArrivedTs < 1000
            && System.currentTimeMillis() - lastMapRightNotArrivedTs > 2000
            && (lastMapTopP ?: -1f) in 0.46 .. 0.53
            && (lastMapBottomP ?: -1f) in 0.27 .. 0.33
            && (lastMapLeftP ?: -1f) in 0.62 .. 0.71
            && lastMapRightP == null
            && anaPathfindingModeYW == MODE_PATHFINDING_P3
        ) {
            // 150 140 90 70
            // [上,0s,0.5188324,c:45][下,0s,0.30617386,c:83][左,0s,0.69376457,c:44][右,79s,c:0]][Road,c:97]
            // [上,0s,0.4861967,c:44][下,0s,0.30365488,c:81][左,0s,0.64833987,c:52][右,120s,c:0]][Road,c:96]
            printLog { "analystYW 节点.P3最右边的卡门.右下角走两步微调B" }
            anaLastSMapYWFeature16Ts = System.currentTimeMillis()
        } else if (System.currentTimeMillis() - lastMapTopNotArrivedTs < 1000
            && System.currentTimeMillis() - lastMapBottomNotArrivedTs < 1000
            && System.currentTimeMillis() - lastMapLeftNotArrivedTs < 1000
            && System.currentTimeMillis() - lastMapRightNotArrivedTs > 2000
            && (lastMapTopP ?: -1f) in 0.24 .. 0.39
            && (lastMapBottomP ?: -1f) in 0.23 .. 0.37
            && (lastMapLeftP ?: -1f) in 0.39 .. 0.54
            && lastMapRightP == null
            && anaPathfindingModeYW == MODE_PATHFINDING_P3
        ) {
            // 270 0 30
            // [上,0s,0.3112119,c:71][下,0s,0.30914095,c:39][左,0s,0.49961844,c:56][右,135s,c:0]][Road,c:74]
            // [上,0s,0.32165444,c:67][下,0s,0.30374664,c:38][左,0s,0.46551207,c:57][右,166s,c:0]][Road,c:73]
            printLog { "analystYW 节点.P3最右边的卡门.左上角走两步微调" }
            anaLastSMapYWFeature17Ts = System.currentTimeMillis()
        } else if (System.currentTimeMillis() - lastMapTopNotArrivedTs < 1000
            && System.currentTimeMillis() - lastMapBottomNotArrivedTs < 1000
            && System.currentTimeMillis() - lastMapLeftNotArrivedTs > 2000
            && System.currentTimeMillis() - lastMapRightNotArrivedTs < 1000
            && (lastMapTopP ?: -1f) in 0.75 .. 0.84
            && (lastMapBottomP ?: -1f) in 0.51 .. 0.65
            && lastMapLeftP == null
            && (lastMapRightP ?: -1f) in 0.55 .. 0.61
            && anaPathfindingModeYW == MODE_PATHFINDING_P4
        ) {
            // 25 30 25 30 25 30 25 30 25 30 25 30
            // [上,0s,0.81715465,c:44][下,0s,0.6269225,c:72][左,16s,c:0][右,0s,0.58505917,c:52]][Road,c:88]
            // [上,0s,0.7903327,c:54][下,0s,0.5649296,c:67][左,34s,c:0][右,0s,0.58903134,c:54]][Road,c:91]
            // [上,0s,0.7647166,c:62][下,0s,0.5385001,c:62][左,49s,c:0][右,0s,0.5839706,c:57]][Road,c:94]
            printLog { "analystYW 节点.P4走过头了.回头触发Boss A" }
            anaLastSMapYWFeature18Ts = System.currentTimeMillis()
        } else if (System.currentTimeMillis() - lastMapTopNotArrivedTs < 1000
            && System.currentTimeMillis() - lastMapBottomNotArrivedTs < 1000
            && System.currentTimeMillis() - lastMapLeftNotArrivedTs > 2000
            && System.currentTimeMillis() - lastMapRightNotArrivedTs < 1000
            && (lastMapTopP ?: -1f) in 0.85 .. 0.93
            && (lastMapBottomP ?: -1f) in 0.52 .. 0.64
            && lastMapLeftP == null
            && (lastMapRightP ?: -1f) in 0.48 .. 0.57
            && anaPathfindingModeYW == MODE_PATHFINDING_P4
        ) {
            // 45 40 45 50 45 40 45 50 45 40 45 50
            // [上,0s,0.9012583,c:22][下,0s,0.55257374,c:72][左,1746536972s,c:0][右,0s,0.51373625,c:56]][Road,c:67]
            // [上,0s,0.8898305,c:25][下,0s,0.6160365,c:65][左,1746536983s,c:0][右,0s,0.5419287,c:53]][Road,c:76]
            printLog { "analystYW 节点.P4走过头了.回头触发Boss B" }
            anaLastSMapYWFeature24Ts = System.currentTimeMillis()
        } else if (System.currentTimeMillis() - lastMapTopNotArrivedTs < 1000
            && System.currentTimeMillis() - lastMapBottomNotArrivedTs < 1000
            && System.currentTimeMillis() - lastMapLeftNotArrivedTs < 1000
            && System.currentTimeMillis() - lastMapRightNotArrivedTs < 1000
            && (lastMapTopP ?: -1f) in 0.67 .. 0.82
            && (lastMapBottomP ?: -1f) in 0.42 .. 0.55
            && (lastMapLeftP ?: -1f) in 0.54 .. 0.66
            && (lastMapRightP ?: -1f) in 0.36 .. 0.50
            && anaPathfindingModeYW == MODE_PATHFINDING_P4
        ) {
            // 45 40 45 50 45 40 45 50 45 40 45 50
            // [上,0s,0.7819903,c:57][下,0s,0.46802047,c:53][左,0s,0.61294264,c:7][右,0s,0.4318058,c:47]][Road,c:91]
            // [上,0s,0.718369,c:76][下,0s,0.46721146,c:56][左,0s,0.59615386,c:6][右,0s,0.40929705,c:49]][Road,c:96]
            // [上,0s,0.7222222,c:75][下,0s,0.48564416,c:61][左,0s,0.59615386,c:6][右,0s,0.42498636,c:47]][Road,c:96]
            // [上,0s,0.73513967,c:71][下,0s,0.52593315,c:61][左,0s,0.6305793,c:9][右,0s,0.45565233,c:53]][Road,c:97]
            printLog { "analystYW 节点.P4走过头了.回头触发Boss C" }
            anaLastSMapYWFeature25Ts = System.currentTimeMillis()
        } else if (System.currentTimeMillis() - lastMapTopNotArrivedTs < 1000
            && System.currentTimeMillis() - lastMapBottomNotArrivedTs < 1000
            && System.currentTimeMillis() - lastMapLeftNotArrivedTs < 1000
            && System.currentTimeMillis() - lastMapRightNotArrivedTs < 1000
            && (lastMapTopP ?: -1f) in 0.42 .. 0.60
            && (lastMapBottomP ?: -1f) in 0.41 .. 0.52
            && (lastMapLeftP ?: -1f) in 0.54 .. 0.66
            && (lastMapRightP ?: -1f) in 0.45 .. 0.56
            && anaPathfindingModeYW == MODE_PATHFINDING_P4
        ) {
            // 45 40 45 50 45 40 45 50 45 40 45 50
            // [上,0s,0.46892655,c:5][下,0s,0.47147447,c:51][左,0s,0.61294264,c:7][右,0s,0.515015,c:37]][Road,c:81]
            // [上,0s,0.5526451,c:11][下,0s,0.46527776,c:48][左,0s,0.61294264,c:7][右,0s,0.515015,c:37]][Road,c:80]
            printLog { "analystYW 节点.P4走过头了.回头触发Boss D" }
            anaLastSMapYWFeature25Ts = System.currentTimeMillis()
        } else if (System.currentTimeMillis() - lastMapTopNotArrivedTs < 1000
            && System.currentTimeMillis() - lastMapBottomNotArrivedTs < 1000
            && System.currentTimeMillis() - lastMapLeftNotArrivedTs < 1000
            && System.currentTimeMillis() - lastMapRightNotArrivedTs < 1000
            && (lastMapTopP ?: -1f) in 0.62 .. 0.74
            && (lastMapBottomP ?: -1f) in 0.38 .. 0.50
            && (lastMapLeftP ?: -1f) in 0.56 .. 0.68
            && (lastMapRightP ?: -1f) in 0.37 .. 0.50
            && anaPathfindingModeYW == MODE_PATHFINDING_P3
        ) {
            // 300 310 300 310 300 310 300 310
            // [上,0s,0.657385,c:56][下,0s,0.42826763,c:89][左,0s,0.6547527,c:33][右,0s,0.47315362,c:39]][Road,c:103]
            // [上,0s,0.718369,c:76][下,0s,0.4677159,c:56][左,0s,0.59615386,c:6][右,0s,0.40929705,c:49]][Road,c:97]
            printLog { "analystYW 节点.P3 实际在boss.直通来的" }
            anaLastSMapYWFeature23Ts = System.currentTimeMillis()
        } else if (System.currentTimeMillis() - lastMapTopNotArrivedTs < 1000
            && System.currentTimeMillis() - lastMapBottomNotArrivedTs < 1000
            && System.currentTimeMillis() - lastMapLeftNotArrivedTs < 1000
            && System.currentTimeMillis() - lastMapRightNotArrivedTs > 2000
            && (lastMapTopP ?: -1f) in 0.16 .. 0.23
            && (lastMapBottomP ?: -1f) in 0.40 .. 0.48
            && (lastMapLeftP ?: -1f) in 0.52 .. 0.74
            && lastMapRightP == null
            && anaPathfindingModeYW == MODE_PATHFINDING_P1
        ) {
            // 190 220 270 330
            // [上,0s,0.20724192,c:11][下,0s,0.45377505,c:11][左,0s,0.71744597,c:17][右,129s,c:0]][Road,c:47]
            // [上,0s,0.20724192,c:11][下,0s,0.45377505,c:11][左,0s,0.71744597,c:17][右,57s,c:0]][Road,c:46]
            // [上,0s,0.19209039,c:15][下,0s,0.4370827,c:11][左,0s,0.55608976,c:24][右,142s,c:0]][Road,c:46]
            printLog { "analystYW 节点.P1开局路往上.卡点往左下走一步" }
            anaLastSMapYWFeature19Ts = System.currentTimeMillis()
        } else if (System.currentTimeMillis() - lastMapTopNotArrivedTs < 1000
            && System.currentTimeMillis() - lastMapBottomNotArrivedTs > 2000
            && System.currentTimeMillis() - lastMapLeftNotArrivedTs > 2000
            && System.currentTimeMillis() - lastMapRightNotArrivedTs < 1000
            && (lastMapTopP ?: -1f) in 0.73 .. 0.83
            && lastMapBottomP == null
            && lastMapLeftP == null
            && (lastMapRightP ?: -1f) in 0.31 .. 0.60
            && anaPathfindingModeYW == MODE_PATHFINDING_P1
        ) {
            // 45 50 45 50 45 50 45 50
            // [上,0s,0.7846352,c:46][下,34s,c:0][左,113s,c:0][右,0s,0.46855345,c:53]][Road,c:37]
            // [上,0s,0.81715465,c:44][下,48s,c:0][左,128s,c:0][右,0s,0.33846152,c:50]][Road,c:29]
            // [上,0s,0.7609784,c:44][下,62s,c:0][左,142s,c:0][右,0s,0.51087123,c:57]][Road,c:38]
            // [上,0s,0.7535647,c:42][下,117s,c:0][左,283s,c:0][右,0s,0.58644134,c:44]][Road,c:41]
            printLog { "analystYW 节点.P1开局路左下区域死路回到主径" }
            anaLastSMapYWFeature20Ts = System.currentTimeMillis()
        } else if (System.currentTimeMillis() - lastMapTopNotArrivedTs < 1000
            && System.currentTimeMillis() - lastMapBottomNotArrivedTs < 1000
            && System.currentTimeMillis() - lastMapLeftNotArrivedTs > 2000
            && System.currentTimeMillis() - lastMapRightNotArrivedTs > 2000
            && (lastMapTopP ?: -1f) in 0.31 .. 0.37
            && (lastMapBottomP ?: -1f) in 0.42 .. 0.50
            && lastMapLeftP == null
            && lastMapRightP == null
        ) {
            // [上,0s,0.3418079,c:5][下,0s,0.4771089,c:29][左,174s,c:0][右,163s,c:0]][Road,c:43]
            // [上,0s,0.34463277,c:16][下,0s,0.4661017,c:30][左,10s,c:0][右,198s,c:0]][Road,c:44]
            printLog { "analystYW 节点.P1开局卡蜡烛墙" }
            anaPathfindingModeYW = MODE_PATHFINDING_P1
        } else if (System.currentTimeMillis() - lastMapTopNotArrivedTs < 1000
            && System.currentTimeMillis() - lastMapBottomNotArrivedTs < 1000
            && System.currentTimeMillis() - lastMapLeftNotArrivedTs < 1000
            && System.currentTimeMillis() - lastMapRightNotArrivedTs > 2000
            && (lastMapTopP ?: -1f) in 0.23 .. 0.35
            && (lastMapBottomP ?: -1f) in 0.23 .. 0.36
            && (lastMapLeftP ?: -1f) in 0.55 .. 0.63
            && lastMapRightP == null
            && anaPathfindingModeYW == MODE_PATHFINDING_P3
        ) {
            // 230 250 270
            printLog { "analystYW 节点.P3右上测墙边卡点" }
            // [上,0s,0.26531944,c:13][下,0s,0.26310834,c:57][左,0s,0.58002347,c:51][右,45s,c:0]][Road,c:61]
            // [上,0s,0.28730473,c:17][下,0s,0.26518363,c:56][左,0s,0.5641026,c:52][右,67s,c:0]][Road,c:62]
            // [上,0s,0.3142112,c:13][下,0s,0.33116037,c:65][左,0s,0.601391,c:51][右,79s,c:0]][Road,c:56]
            // [上,0s,0.32344633,c:12][下,0s,0.33457455,c:66][左,0s,0.5907112,c:53][右,88s,c:0]][Road,c:57]
            // [上,0s,0.26911104,c:49][下,0s,0.25887814,c:56][左,0s,0.5854701,c:50][右,112s,c:0]][Road,c:70]
            // [上,0s,0.2745652,c:51][下,0s,0.26310834,c:57][左,0s,0.5641026,c:50][右,124s,c:0]][Road,c:70]
            // [上,0s,0.27034944,c:27][下,0s,0.3357787,c:67][左,0s,0.5907112,c:53][右,136s,c:0]][Road,c:69]
            anaLastSMapYWFeature21Ts = System.currentTimeMillis()
        } else if (System.currentTimeMillis() - lastMapTopNotArrivedTs < 1000
            && System.currentTimeMillis() - lastMapBottomNotArrivedTs < 1000
            && System.currentTimeMillis() - lastMapLeftNotArrivedTs < 1000
            && System.currentTimeMillis() - lastMapRightNotArrivedTs > 2000
            && (lastMapTopP ?: -1f) in 0.25 .. 0.39
            && (lastMapBottomP ?: -1f) in 0.40 .. 0.52
            && (lastMapLeftP ?: -1f) in 0.82 .. 0.90
            && lastMapRightP == null
            && anaPathfindingModeYW == MODE_PATHFINDING_P1
            && System.currentTimeMillis() - xLastAtkTs > 8000
        ) {
            // 120 140 120 140 atk 80 atk
             // [上,0s,0.37288135,c:14][下,0s,0.42231637,c:6][左,0s,0.87393165,c:12][右,414s,c:0]][Road,c:51]
            printLog { "analystYW 节点.P1开局卡树怪" }
            // [上,0s,0.2881356,c:12][下,0s,0.4905838,c:21][左,0s,0.8575499,c:15][右,1745760215s,c:0]][Road,c:50]
            // [上,0s,0.3348544,c:13][下,0s,0.47376916,c:14][左,0s,0.8665351,c:13][右,1745760228s,c:0]][Road,c:49]
            // [上,0s,0.3489787,c:13][下,0s,0.47578692,c:14][左,0s,0.8575499,c:15][右,1745760273s,c:0]][Road,c:49]
            // [上,0s,0.29139504,c:13][下,0s,0.48305085,c:20][左,0s,0.8681788,c:13][右,1745760286s,c:0]][Road,c:48]
            anaLastSMapYWFeature22Ts = System.currentTimeMillis()
        }
    }

    if (System.currentTimeMillis() - anaLastPageSceneEnterTs > 8000
        && System.currentTimeMillis() - xLastUnknownTs > 8000
        && System.currentTimeMillis() - anaLastHasEnemyNameTs > 4000
        && System.currentTimeMillis() - lastEliteEnemyBossTs > 4000
        && blockBlueDoor != null
        && blockBlacksmith != null
        && !bsSceneSettle && !bsSceneSettleBlacksmith
        && simpleAssertSceneCompleted(blockBlueDoor, blockBlacksmith)) { // 特有判定
        printLog { "analyst scene completed count $anaCounterSceneSettle" }
        anaCounterSceneSettle++
        if (anaCounterSceneSettle > 0) {
            printLog { "analyst scene completed" }
            anaMarkSceneSettle()
        }
    }
    if (System.currentTimeMillis() - lastBlueDoorTs > 3000
        && System.currentTimeMillis() - lastBlacksmithTs > 3000) {
        anaCounterSceneSettle = 0
    }
}

fun analysisMapYWIsStartPoint(): Boolean {
    if ((blockBlueDoor == null || blockBlacksmith == null)
        && System.currentTimeMillis() - lastEliteEnemyBossTs > 10000) {
        if (System.currentTimeMillis() - lastMapTopNotArrivedTs < 1000
            && System.currentTimeMillis() - lastMapBottomNotArrivedTs > 2000
            && System.currentTimeMillis() - lastMapLeftNotArrivedTs < 1000
            && System.currentTimeMillis() - lastMapRightNotArrivedTs > 2000
            && (lastMapTopP ?: -1f) in 0.21 .. 0.34
            && lastMapBottomP == null
            && (lastMapLeftP ?: -1f) in 0.16 .. 0.49
            && lastMapRightP == null
            && System.currentTimeMillis() - lastBlueDoorTs < 3000) {
            // [上,0s,0.26271185,c:64][下,1741875848s,c:0][左,0s,0.4382716,c:18][右,1741875848s,c:0]][Road,c:24]
            // [上,0s,0.29015335,c:56][下,1741875878s,c:0][左,0s,0.33760685,c:22][右,1741875878s,c:0]][Road,c:20]
            // [上,0s,0.32683614,c:50][下,47s,c:0][左,0s,0.19951923,c:16][右,1746171310s,c:0]][Road,c:15]
            printLog { "analystYW 节点.遗忘副本起点A " } // maybe//  [可以用sampleCount来区分] // boss前也有这个
            anaLastSMapYWFeature1Ts = System.currentTimeMillis()
            anaPathfindingModeYW = MODE_PATHFINDING_P1
            anaClearSceneSettle()
            return true
        } else if (System.currentTimeMillis() - lastMapTopNotArrivedTs < 1000
            && System.currentTimeMillis() - lastMapBottomNotArrivedTs > 2000
            && System.currentTimeMillis() - lastMapLeftNotArrivedTs > 2000
            && System.currentTimeMillis() - lastMapRightNotArrivedTs > 2000
            && (lastMapTopP ?: -1f) in 0.42 .. 0.49
            && lastMapBottomP == null
            && lastMapLeftP == null
            && lastMapRightP == null) {
            printLog { "analystYW 节点.遗忘副本起点B " } // maybe//  [可以用sampleCount来区分] // boss前也有这个
            // [上,0s,0.4614792,c:33][下,1745591034s,c:0][左,1745591034s,c:0][右,1745591034s,c:0]][Road,c:12]
            // [上,0s,0.4614792,c:33][下,120s,c:0][左,152s,c:0][右,192s,c:0]][Road,c:13]
            // [上,0s,0.45762712,c:34][下,1745634105s,c:0][左,1745634105s,c:0][右,1745634105s,c:0]][Road,c:11]
            // [上,0s,0.4614792,c:33][下,12s,c:0][左,14s,c:0][右,12s,c:0]][Road,c:13]
            // [上,0s,0.46127212,c:31][下,1746171407s,c:0][左,1746171407s,c:0][右,1746171407s,c:0]][Road,c:12]
            anaLastSMapYWFeature1Ts = System.currentTimeMillis()
            anaPathfindingModeYW = MODE_PATHFINDING_P1
            anaClearSceneSettle()
            return true
        }
    }
    return false
}

private fun simpleAssertSceneCompleted(blueDoor: Block?, blacksmith: Block?): Boolean {
    if (blueDoor == null) return false
    if (blacksmith == null) return false
    val edge = 80.pt
    return (abs(blueDoor.x - blacksmith.x) < edge && abs(blueDoor.y - blacksmith.y) < edge)
}

private fun angleSpecialAdjust(angle: Int): Int {
    if (System.currentTimeMillis() - anaLastHasEnemyBossNameTs > 3000
        && System.currentTimeMillis() - lastEliteEnemyTs > 3000
        && System.currentTimeMillis() - lastEliteEnemyBossTs > 3000
        && System.currentTimeMillis() - lastMapRedDotTs > 3000
        && System.currentTimeMillis() - xLastAtkTs < 600
        && System.currentTimeMillis() - sLastFeature30Ts > 1600) {
        printLog { "analystYW 回撤清理漏怪" }
        sLastFeature30Ts = System.currentTimeMillis()
        return (angle + 180) % 360
    }

    if (angle in 0 .. 280) {
        if (System.currentTimeMillis() - xLastAtkTs > 5000
            && System.currentTimeMillis() - lastEliteEnemyBossTs > 5000
            && System.currentTimeMillis() - lastEliteEnemyTs > 5000
            && System.currentTimeMillis() - xLastSceneEnterTs > 30000
            && System.currentTimeMillis() - xLastPetBlacksmithTs > 20000
            && System.currentTimeMillis() - xLastUnknownTs < 20000) {
            printLog { "analystYW angleSpecialAdjust $angle to 330" }
            return 330
        }
    }
    return angle
}